package com.bossly.metro;

import android.content.Context;
import android.content.SharedPreferences;

public class PreferenceWrapper {

	private static final String PREFERENCE_NAME = "default";

	private static final String PREF_SELECTED_CITY = "selectedCity";

	private static final String PREF_START_STATION = "start_station";

	private static final String PREF_FINISH_STATION = "finish_station";

	static PreferenceWrapper preferences;
	private final SharedPreferences m_preferences;

	public static PreferenceWrapper getInstance(Context context) {
		if (preferences == null)
			preferences = new PreferenceWrapper(context);

		return preferences;
	}

	public PreferenceWrapper(Context context) {

		m_preferences = context.getSharedPreferences(PREFERENCE_NAME,
				Context.MODE_PRIVATE);
	}

	public int getSelectedCity() {
		return m_preferences.getInt(PREF_SELECTED_CITY, -1);
	}

	public void setSelectedCity(int city) {
		m_preferences.edit().putInt(PREF_SELECTED_CITY, city).commit();
	}

	public int getStartStation() {
		return m_preferences.getInt(PREF_START_STATION, -1);
	}

	public int getFinishStation() {
		return m_preferences.getInt(PREF_FINISH_STATION, -1);
	}

	public void setStartStation(int station) {
		m_preferences.edit().putInt(PREF_START_STATION, station).commit();
	}

	public void setFinishStation(int station) {
		m_preferences.edit().putInt(PREF_FINISH_STATION, station).commit();
	}
}
